<template>
  <div v-loading="listLoading">
    <div class="form">
      <form th:object="${entList}">
        <input id="entname" name="entname" th:field="*{entname}" type="hidden" />
        <input id="pci_picurl" name="pci_picurl" th:field="*{pci_picurl}" type="hidden" />
        <input id="elecCustomerId" name="elecCustomerId" th:field="*{elecCustomerId}" type="hidden" />
        <input id="entId" name="entId" th:field="*{entId}" type="hidden" />
        <div id="maindiv">
          <div class="buttonWrapper">
            <span>
              <a class="xiaobiao" @click="getPdf()">下载</a>
            </span>
            <!-- <span style="display:inline-block;">
					<a class="xiaobiao"  href="#" onclick="doPrint()">打印</a>
            </span>-->
            <!-- <span style="display:inline-block;">
					<a class="xiaobiao"  href="#" onclick="downLoad()">下载至本地</a>
            </span>-->
            <!-- <span style="display:inline-block;">
					<a class = "xiaobiao" href="#" onclick="sendReport()">发送至邮箱</a>
            </span>-->
          </div>
          <!--startprint-->
          <div id="content" v-html="reportHtml" class="centers pdfDom"></div>
          <!--endprint-->
        </div>
      </form>
    </div>
  </div>
</template>
<script>
import { creditReport } from "@/api/system/user";
import { MessageBox } from "element-ui";
export default {
  components: {},
  data() {
    return {
      workCode: "",
      workStatus: "",
      status: [],
      list: [],
      listLoading: false,
      total: 0,
      limit: 10,
      curPage: 1,
      listData: [],
      detailShow: false,
      creditReports: false,
      value: "",
      reportHtml: "",
      htmlTitle: "信用报告",
      needData: [],
      loanList: [],
      moneyList: [],
      infoShow: "0",
      proType: "",
      sellMoney: "",
      orgnise: {
        key: "",
        value: ""
      },
      applyShow: false,
      creditShow: false,
      productName: "",
      customerName: "",
      addShow: false,
      guaranteeTypeList: [],
      approveId: "",
      guaranteeType: "",
      approveAmount: "",
      stepNum: null,
      stepList: [],
      addData: [],
      creditList: [],
      provinceData: [],
      mortgageList: [],
      reqId: "",
      flowUid: "",
      createTime: "",
      taskNo: "",
      roles: "",
      checkShow: false,
      rejectReason: "",
      goodsList: [],
      entName: "",
      customerId: "",
      label: "",
      showTips: true,
      status1: "",
      addCreditShow: false,
      approveContractNo: "",
      ifFirstApprove: "",
      approveStart: "",
      approveEnd: "",
      aproveList: [{ key: "0", value: "是" }, { key: "1", value: "否" }],
      creditTotal: "",
      productType: "",
      statusFlag: [],
      customerId: ""
    };
  },
  created() {
    this.roles = this.$store.state.user.roles[0];
  },
  mounted() {
    this.customerId = decodeURI(this.$route.query.val);
    this.toMoveCreditReport(this.customerId);
  },
  methods: {
    doPrint(index) {
      this.$confirm(
        "如需下载安信小宝报告，可在打印预览页面将报告选择[另存为PDF]至本地",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "info"
        }
      )
        .then(() => {
          this.executePrint();
        })
        .catch(() => {});
    },
    executePrint() {
      window.document.body.innerHTML = this.reportHtml;
      window.print();
    },
    /** 信用报告 */
    toMoveCreditReport(customerId) {
      this.listLoading = true;
      creditReport(customerId).then(res => {
        if (res.code == 200) {
          if (res.data) {
            if (res.data.code == 100100) {
              this.reportHtml = res.data.reportContent;
            } else if (res.data.code == 100100) {
              this.$msgbox(res.data.message);
            } else {
              this.$msgbox(res.data.reportContent);
            }
          }
        } else {
          this.$message({ message: res.msg, type: "error" });
        }
        this.listLoading = false;
      });
    }
  }
};
</script>

 <style scoped src='../../../assets/styles/summernote.css'></style>
 <style scoped src='../../../assets/styles/summernote-bs3.css'></style>
<style scoped>
.form {
  padding-left: 26px;
  padding-right: 24px;
  padding-top: 24px;
  background: #fff;
}
.search {
  display: flex;
  position: relative;
}
.search_info {
  width: 180px;
  height: 40px;
  margin-right: 16px;
}
.searchBtn {
  margin-left: 16px;
  height: 36px;
}
.sortStyle {
  height: 19px;
  float: right;
  /* right: 24px; */
  margin-top: 20px;
  margin-bottom: 30px;
}
.pos_right_btn {
  position: absolute;
  right: 0;
}
.opt_font {
  cursor: pointer;
  color: #2e82ff;
}
.detail_title {
  font-size: 16px;
  font-weight: 400;
  color: #212121;
  line-height: 22px;
}
.detail_title span {
  padding-left: 4px;
  background: #1e88e5;
  margin-right: 12px;
}
.row {
  display: flex;
  /* padding-bottom: 12px; */
}
.detail_info {
  padding-top: 16px;
}
.info_left {
  display: flex;
}
.info_right {
  display: flex;
  /* padding-left: 202px; */
}
.info_left_title {
  font-size: 14px;
  font-weight: 400;
  color: #616161;
  line-height: 20px;
  width: 256px;
  /* margin-right: 16px; */
  text-align: center;
  min-height: 47px;
  background: #f5f7fa;
  box-shadow: inset 0 -1px 0 0 #dcdfe6;
}
.info_left_title .font {
  position: relative;
  top: 14px;
}
.info_left_content {
  font-size: 14px;
  font-weight: 400;
  color: #212121;
  line-height: 20px;
  width: 256px;
  /* border: 1px solid #DCDFE6; */
  box-shadow: inset -1px -1px 0 0 #dcdfe6;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.info_left_contents {
  font-size: 14px;
  font-weight: 400;
  color: #212121;
  line-height: 20px;
  width: 769px;
  /* border: 1px solid #DCDFE6; */
  box-shadow: inset -1px -1px 0 0 #dcdfe6;
  text-align: left;
}
.pos_top {
  padding-top: 12px;
}
.top_more {
  margin-top: 8px;
}
.detailTable {
  margin-top: 16px;
}
.opt_font {
  color: #1e88e5;
  cursor: pointer;
}
.page_pos {
  text-align: right;
  padding-top: 10px;
}
.backBtn {
  text-align: center;
  margin-top: 10px;
}
/deep/ .el-dialog {
  display: flex;
  flex-direction: column;
  margin: 0 !important;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: calc(100% -30px);
  /* max-width: ; */
}
/deep/ .el-dialog__body {
  /* flex: 1; */
  height: 600px;
  overflow-y: auto;
  padding-top: 0;
}
.tab {
  display: flex;
  position: absolute;
  right: 55px;
  top: 14px;
}
.tab_border {
  border: 1px solid #409eff;
  color: #409eff;
  padding: 10px 12px;
  font-size: 14px;
  width: 82px;
  margin-right: 16px;
  text-align: center;
}
.change {
  border: 1px solid grey;
  color: grey;
  /* width: 82px; */
}
.changes {
  border: 1px solid #f56c6c;
  color: #f56c6c;
  /* width: 82px; */
}
.listTable {
  margin-top: 17px;
}
/deep/ .search_info .el-input__inner {
  width: 180px;
}
.date_picker /deep/ .el-input__inner {
  width: 240px;
}
.opt_table {
  display: flex;
  justify-content: space-around;
}
.footer {
  display: flex;
  justify-content: space-between;
}
.footer_btn {
  position: relative;
  top: 20px;
}
.dia_top {
  display: flex;
}
.dia_color {
  color: #409eff;
}
.pad_right {
  padding-right: 16px;
}
.statuBtn {
  padding: 10px 14px;
  font-size: 14px;
  margin-right: 16px;
  border: 1px solid #f56c6c;
  color: #f56c6c;
  width: 102px;
  text-align: center;
  margin-top: 14px;
  margin-bottom: 14px;
}
.statuBtns {
  padding: 10px 14px;
  font-size: 14px;
  margin-right: 16px;
  border: 1px solid #18b5a6;
  color: #18b5a6;
  width: 102px;
  text-align: center;
  margin-top: 14px;
  margin-bottom: 14px;
}
.step_top {
  position: relative;
  top: 14px;
}
.step {
  display: flex;
  justify-content: space-around;
}
.step_width {
  width: 200px;
  text-align: center;
  padding-bottom: 8px;
}
.comBtn {
  display: flex;
  position: absolute;
  right: 0;
  top: -8px;
}
.det_flex {
  display: flex;
  position: relative;
}
.btnCol {
  margin-right: 14px;
}
.flex_row {
  display: flex;
  justify-content: center;
}
.tap {
  display: flex;
}
.tap_left {
  border: 1px solid #1e88e5;
  padding: 6px 8px;
  background: #1e88e5;
  color: #fff;
  cursor: pointer;
}
.tap_right {
  background: #1e88e5;
  border: 1px solid #1e88e5;
  padding: 6px 8px;
  margin-left: 10px;
  color: #fff;
  cursor: pointer;
}
.input_info {
  width: 200px;
}
.select_info {
  width: 200px;
}
.font_info {
  width: 120px;
  position: relative;
  top: 8px;
  text-align: right;
  margin-right: 16px;
}
.centers {
  /* display: flex; */
  text-align: center;
}
.pad_top {
  padding-top: 10px;
}
.footers {
  margin-top: 30px;
  text-align: center;
}
.apply /deep/ .el-dialog__body {
  height: 200px;
}
.credit /deep/ .el-dialog__body {
  height: 400px;
}
.creditReport /deep/ .el-dialog__body {
  height: 600px;
}
.addCredits /deep/ .el-dialog__body {
  height: 240px;
}
/deep/ .check .el-dialog__body {
  /* flex: 1; */
  height: 200px;
  overflow-y: auto;
  padding-top: 0;
}
.btn_top {
  padding-top: 20px;
}
</style>
<style type="text/css">
#creditReport {
  font-family: SimSun;
}
#contents {
  padding: 20px;
}
@page {
  size: A4;
  margin: 0.25in;
  -fs-flow-bottom: "footer";
  -fs-flow-left: "left";
  -fs-flow-right: "right";
  padding: 12em;
  @bottom-right {
    content: counter(page) "/" counter(pages);
  }
}
#maindiv {
  width: 70%;
  border-image-source: initial;
  border-image-slice: initial;
  border-image-width: initial;
  border-image-outset: initial;
  border-image-repeat: initial;
  margin-top: 30px;
  margin-left: 150px;
  border-width: 1px;
  border-style: solid;
  border-color: rgb(231, 233, 239);
}
.xiaobiao {
  text-decoration: none;
  color: black;
  text-align: center;
  display: inline-block;
  width: 120px;
  height: 36px;
  border: 1px solid #e2dddd;
  line-height: 36px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 300;
}
.buttonWrapper {
  position: fixed;
  margin-top: 10px;
  right: 25%;
  background: #fff;
}
.addIcon {
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #1890ff;
  cursor: pointer;
  height: 40px;
  border-left: 1px solid #dfe6ec;
  border-right: 1px solid #dfe6ec;
  border-bottom: 1px solid #dfe6ec;
}
.addIcon img {
  width: 12px;
  height: 12px;
  margin-right: 8px;
  position: relative;
  top: 1px;
}
</style>
<style rel="stylesheet" type="text/css" media="print">
#contents {
  padding-right: 20mm;
}
</style>
